package Generic;

import java.util.ArrayList;
import java.util.Iterator;

public class Generic_use {
    public static void main(String[] args) {
        Generic<String> name = new Generic<String>();
        name.setName("王二狗");
        System.out.println(name.getName());
        Generic obj = new Generic();
        //不写默认为Object类型
        obj.setName(123);
        System.out.println(obj.getName());
        //
        Interface_genericImpl impl = new Interface_genericImpl();
        impl.method("林颖超的唧唧");
        Interface_genericImpl2<String> impl2 = new Interface_genericImpl2<String>();
        impl2.method("林颖超的基基");
        ArrayList<Integer> a = new ArrayList<>();
        a.add(1);a.add(2);a.add(3);
        print(a);

    }
    public static void print(ArrayList<?> list)
    {
        Iterator<?> it = list.iterator();
        while(it.hasNext())
        {
            Object o = it.next();
            System.out.println(o);
        }
    }
}
